#include "log.h"

FormattingChannel* g_pFileChannel = NULL;

void InitFileLogger(string log_file_name)
{
    g_pFileChannel = new FormattingChannel(new PatternFormatter("%Y-%m-%d %H:%M:%S.%c %N[%P]:%s:%q:%t"));
    g_pFileChannel->setChannel(new FileChannel(log_file_name));
    g_pFileChannel->open();

    Logger& fileLogger    = Logger::create("FileLogger", g_pFileChannel, Message::PRIO_TRACE);
}

void UnInitFileLogger()
{
    g_pFileChannel->close();
}

FunctionLogger::FunctionLogger( string func ):m_function_name(func)
{
    FLogger.log("entering function [" + m_function_name + "]");
}

FunctionLogger::~FunctionLogger()
{
    FLogger.log("leaving  function [" + m_function_name + "]");
}